package com.work.vo.main;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.constant.DictBizConstant;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 退关提货VO
 *
 * @author ：dujianyu
 * @since ：Created in 2024/5/28 10:06
 */
@Data
public class RetreatTallyVO {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long tallyId;

    @ApiModelProperty(value = "来源表")
    private String stockType;

    @ApiModelProperty(name = "理货时间",notes = "")
    private LocalDate tallyDate;

    @ApiModelProperty(name = "时间段",notes = "")
    private String timeSpace;

    @ApiModelProperty(name = "时间段",notes = "")
    private String timeSpaceName;

    public String getTimeSpaceName() {
        if (Func.isNull(timeSpace)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(name = "理货类型",notes = "")
    private String tallyType;

    @ApiModelProperty(name = "理货类型",notes = "")
    private String tallyTypeName;

    public String getTallyTypeName() {
        if (Func.isNull(tallyType)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TALLY_TYPE, tallyType);
    }

    /** 去向理货件数 */
    @ApiModelProperty(name = "去向理货件数",notes = "")
    private Integer tallyPiece ;

    /** 去向理货吨数 */
    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(name = "去向理货吨数",notes = "")
    private BigDecimal tallyTon ;

    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @ApiModelProperty(name = "创建时间",notes = "")
    private LocalDateTime createTime;

    @ApiModelProperty(name = "创建人",notes = "")
    private String createUserName;

}
